<?php
/* @var $this TaskController */
/* @var $model Task */
/* @var $form CActiveForm */
if(Yii::app()->user->name === 'admin'){ 

Yii::app()->clientScript->registerScript('district', "
//$('#selectcity').prepend('<option>test');

$('#selectcity').on('change',function() {
	
	var val= $('#selectcity').val();
	$('#Task_district').val(val);
});
");
}

?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'task-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>
	<?php if(Yii::app()->user->name === 'admin'){ ?>
	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
	
		<?php
		    echo $form->dropDownList(
		            $model, 
		            'name', 
		            array('send'=>'send','check'=>'check')
		      );
		?>
		<?php echo $form->error($model,'name'); ?>
	</div>
	<?php } ?>
	<div class="row">
		<?php echo $form->labelEx($model,'content'); ?>
		<?php echo $form->textArea($model,'content',array('rows'=>10,'cols'=>40,'class'=>'ios_emoji')); ?>
		<?php echo $form->error($model,'content'); ?>
	</div>

	<div class="row">
		<?php if(Yii::app()->user->name === 'admin'){ ?>
		<?php echo $form->labelEx($model,'district'); ?>
		
		<?php echo $form->textField($model,'district'); ?>
		<?php
		    echo CHtml::dropDownList(
		            "selectcity", 
		            '', 
		            Globals::province(),
		            array('empty'=>array('all'=>'全国'))
		      );
		?>
		<?php echo $form->error($model,'district'); ?>
		<?php } else {
			echo $model->district;
		} ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'sendofmax'); ?>
		<?php echo $form->textField($model,'sendofmax'); ?>
		<?php echo $form->error($model,'sendofmax'); ?>
	</div>
	<?php if(Yii::app()->user->name === 'admin'){ ?>

	<div class="row">
		<?php echo $form->labelEx($model,'toindex'); ?>
		<?php echo $form->textField($model,'toindex'); ?>
		<?php echo $form->error($model,'toindex'); ?>
	</div>

	
	<div class="row">
		<?php echo $form->labelEx($model,'sendtoday'); ?>
		<?php echo $form->textField($model,'sendtoday'); ?>
		<?php echo $form->error($model,'sendtoday'); ?>
	</div>
	<?php } ?>
 
	<div class="row">
		<?php echo $form->labelEx($model,'starttime'); ?>

		<?php 
		$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			'language'=>'zh_cn',
			'name'=>'Task[starttime]',
			'options'=>array(
				'showAnim'=>'fold',
				'showOn'=>'both',
				'minDate'=>'new Date()',
				'dateFormat'=>'yy-mm-dd',
			),
			'htmlOptions'=>array(
				'style'=>'height:18px',
			),
		));
		?>


		<?php echo $form->error($model,'starttime'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'endtime'); ?>
		<?php 
		$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			'language'=>'zh_cn',
			'name'=>'Task[endtime]',
			'options'=>array(
				'showAnim'=>'fold',
				'showOn'=>'both',
				'minDate'=>'new Date()',
				'dateFormat'=>'yy-mm-dd',
			),
			'htmlOptions'=>array(
				'style'=>'height:18px',
			),
		));
		?>
		<?php echo $form->error($model,'endtime'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->